<style>
    .custom-control-char { position: absolute; font-style: normal; width: 3rem; height: 3rem; border-radius: 50%; left: 0; top: 0; }
    .custom-control-char img { width: 3rem; height: 3rem; border-radius: 2px; }
    .todo__info { display: inline; }
    .todo__item small { margin-top: 0; }
  #my-video{
      width: 650px;
      height: 550px;
  }
</style>
<script>

   function videosart(id) {
        var options = {
        };
        var player = videojs('my-video', options, function onPlayerReady() {
            var time1;
            var t1 = 0;
            function aa() {
                t1 += 1;
                document.getElementById('aa').value = t1;
                console.log('aa-' + t1);
            }
            //开始播放视频时，设置一个定时器，每250毫秒调用一次aa(),观看时长加2.5秒
            this.on('play', function () {
                console.log('开始播放');
                time1 = setInterval(function () {
                    aa();
                }, 1000)
            });
            //结束和暂时时清除定时器，并向后台发送数据
            this.on('ended', function () {
                console.log('结束播放');
                window.clearInterval(time1);
              //  alert($('#aa').val())
                var seetime=s_to_hs($('#aa').val())
            if(seetime=='00'){
                seetime='01';
            }
                countTime(id,seetime);   //向后台发数据
            });
            this.on('pause', function () {
                console.log('暂停播放');
                window.clearInterval(time1);
            // countTime();  //向后台发数据

            });
        });
        //直接关闭页面，并向后台发送数据
        // if(window.addEventListener){
        //     window.addEventListener("beforeunload",countTime,false);
        // }else{
        //     window.attachEvent("onbeforeunload",countTime);
        // }
    }
   /**
    * 将秒转换为 分:秒
    * s int 秒数
    */
   var seetime='0';
   function s_to_hs(s){
       //计算分钟
       //算法：将秒数除以60，然后下舍入，既得到分钟数
       var h;
       h  =   Math.floor(s/60);
       //计算秒
       //算法：取得秒%60的余数，既得到秒数
       s  =   s%60;
       //将变量转换为字符串
       h    +=    '';
       s    +=    '';
       //如果只有一位数，前面增加一个0
       h  =   (h.length==1)?'0'+h:h;
       s  =   (s.length==1)?'0'+s:s;

     //  return h+':'+s;
       return h;
   }
    function countTime(id,setim) {
        $.ajax({
            url : "task/update",
            type : "POST",
            dataType : 'json',
            data : {'sminute':setim,'prisonerNo':id},
            success:function (data) {
                if(data.code=='0'){
                    $MB.n_success(data.msg);
                    window.setTimeout(function(){
                        window.location.reload()
                    },1000);
                }
            }
        })
    }

 //function videosart(){
    //     var options = {
    //         controls : false,
    //     };
    //
    //     var player = videojs('my-video', options, function onPlayerReady() {
    //         videojs.log('播放器已经准备好了!');
    //
    //         this.play();
    //
    //         this.on('ended', function() {
    //             console.log(this.duration())
    //             videojs.log('播放结束了!');
    //         });
    //     });
    // }
</script>
<div class="modal fade" id="movie-comments" data-keyboard="false" data-backdrop="static" tabindex="-1">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title pull-left" id="movie-comments-modal-title">影片评论</h3>
            </div>
            <div class="modal-body" style="  height: 600px; " id="listview--bordered">
                <!--<div class="listview listview&#45;&#45;bordered">-->
                <!---->
                <!--</div>            -->

                <!--<div class="m" style="  height: 600px; "><video id="my-video" class="video-js" controls preload="auto" width="650" height="590" poster="m.jpg" data-setup="{}"><source src="http://vjs.zencdn.net/v/oceans.mp4" type="video/mp4"></video> </div>-->
          <!---->
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-secondary btn-close" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
